﻿using DotNetStar.TheKing.Domain;
using DotNetStar.TheKing.Services;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace DotNetStar.TheKing.Web
{
    public class UserRankViewComponent:ViewComponent
    {
        private UserService _userService;

        public UserRankViewComponent(UserService userService)
        {
            _userService = userService;
        }

        public async Task<IViewComponentResult> InvokeAsync(Infrastructure.UserTopOrderBy rankType,int top=10)
        {
            var users = await _userService.GetTopUserAsync(top, rankType);
            ViewData["RankType"] = rankType;
            return View(users);
        }
    }
}
